package com.sunwayworld.basemodule.business.ordertask.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.business.ordertask.dao.LimsRunBoardHoleDao;
import com.sunwayworld.basemodule.business.ordertask.bean.LimsRunBoardHoleBean;
import com.sunwayworld.basemodule.business.ordertask.service.LimsRunBoardHoleService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsRunBoardHoleServiceImpl implements LimsRunBoardHoleService {

    @Autowired
    private LimsRunBoardHoleDao limsRunBoardHoleDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsRunBoardHoleDao getDao() {
        return limsRunBoardHoleDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsRunBoardHoleBean limsRunBoardHole = jsonWrapper.parseUnique(LimsRunBoardHoleBean.class);
        limsRunBoardHole.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsRunBoardHole);
        return limsRunBoardHole.getId();
    }

}
